'use strict';

const Controller = require('egg').Controller;
class AddCartController extends Controller {
  async index() {
    const { ctx } = this;
    var {id} = ctx.request.body
    try{
        var res = await ctx.model.User.updateOne({},{$pull:{cartList:{_id:id}}})
        if(res.nModified){
            ctx.body ={
                code:200,
                msg:'删除购物车成功'
            }
        }
    }catch(err){
        ctx.body={
            code:400,
            msg:'输入的参数不合法'
        }
    }
   
    
  }
}
module.exports = AddCartController;